package cn.kingyang.yiyi.ui.fragment;

import android.support.v7.widget.GridLayoutManager;
import android.util.Log;
import android.view.View;

import com.jtech.listener.OnItemClickListener;
import com.jtech.view.JRecyclerView;
import com.jtech.view.RecyclerHolder;

import java.util.List;

import butterknife.BindView;
import cn.kingyang.yiyi.R;
import cn.kingyang.yiyi.mvp.model.bean.Forum;
import cn.kingyang.yiyi.mvp.presenter.MyPresenter;
import cn.kingyang.yiyi.mvp.view.MyView;
import cn.kingyang.yiyi.ui.adapter.ForumInfoAdapter;
import cn.kingyang.yiyi.ui.fragment.base.BaseMainFragment;
import cn.kingyang.yiyi.utils.AppUtil;

import static com.bumptech.glide.gifdecoder.GifHeaderParser.TAG;


/**
 * Created by Administrator on 2017/2/28.
 */

public class MyFragment extends BaseMainFragment<MyView, MyPresenter> implements MyView, OnItemClickListener{
    @BindView(R.id.my_video_jr)
    JRecyclerView mVideoJRV;//
    private ForumInfoAdapter mVideoAdapter;//
    public static MyFragment newInstance() {
        return new MyFragment();
    }

    @Override
    protected MyPresenter getPresenter() {
        return new MyPresenter();
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_my;
    }
    @Override
    protected void initView(View view) {
        mVideoAdapter =new ForumInfoAdapter(_mActivity);
        mVideoJRV.setLayoutManager(new GridLayoutManager(getActivity(),1));
        mVideoJRV.setAdapter(mVideoAdapter);
        mVideoJRV.setOnItemClickListener(this);
        mPresenter.getForumInfo();
    }
    @Override
    public void showProgress() {

    }
    @Override
    public void hideProgress() {

    }
    @Override
    public void onError(Throwable t) {

    }

    @Override
    public void onStart() {
        super.onStart();
        Log.e(TAG, "onStart: ");
    }
    @Override
    public void onResume() {
        super.onResume();
        Log.e(TAG, "onResume: ");
    }

    @Override
    public void onItemClick(RecyclerHolder recyclerHolder, View view, int i) {
        AppUtil.showPopupWindow(_mActivity,getView());
    }

    @Override
    public void doForumInfo(List<Forum> data) {
        mVideoAdapter.setDatas(data);
    }
}
